﻿<!DOCTYPE html>
<!--安全管理师培训管理-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>

<body>
    
<div id="app" v-cloak>   
        <el-row>
            
            <el-col :span="24">
                <el-form ref="form" :inline="true" label-position="right" label-width="100px" :model="formInline"
                    class="demo-form-inline" style="margin-bottom: 15px;">
                    <el-row>
                        <el-col class="head-tool">
                            
<div class="new_title fl"><strong><img src="/static/images/icon1.png" />安全管理师培训管理列表</strong></div>
<span>
    <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3"
         @click="onSubmit"></btn>
    <btn :text="col.btnAdd" linetype="3" @click="UserAdd"></btn>
    <btn-uploadfile-list url="/api/ZB_SafetyTrainer/Import" linetype="3"></btn-uploadfile-list>
    <btn-export-list url="/api/ZB_SafetyTrainerDetail/Export" :forminline="this.formInline" linetype="3">
    </btn-export-list>
    <btn :text="col.Template" imgsrc="/static/images/general.png" linetype="4"
         @click="Template"></btn>

</span>
                        </el-col>
                    </el-row>
                    <el-row class="popupW100">
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{"工厂"+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.createFactory" slot="suffix" placeholder="请选择">
                                            <el-option label="全部" value=""></el-option>
                                            <el-option v-for="item in createFactory" :label="item.value" :value="item.key"></el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.name" :placeholder="SafetyManagerTraining.name"
                                              size="mini">
                                        <template slot="prepend">
                                            {{SafetyManagerTraining.name+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{"年度"+mark.m}}
                                        </template>
                                        <el-date-picker v-model="formInline.model.createTime" type="year"
                                                        slot="suffix" size="mini" placeholder="选择年份">
                                        </el-date-picker>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{SafetyManagerTraining.type+mark.m}}
                                        </template>
                                        <el-select @visible-change="visibleChange" v-model="formInline.model.type" slot="suffix"
                                                   :placeholder="SafetyManagerTraining.type">
                                            <el-option label="请选择" value=""></el-option>
                                            <el-option v-for="item in type" :label="item.value" :value="item.id">
                                            </el-option>
                                        </el-select>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.trainedNumber"
                                              :placeholder="SafetyManagerTraining.trainedNumber" size="mini">
                                        <template slot="prepend">
                                            {{SafetyManagerTraining.trainedNumber+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input v-model="formInline.model.trainMain"
                                              :placeholder="SafetyManagerTraining.trainMain" size="mini">
                                        <template slot="prepend">
                                            {{SafetyManagerTraining.trainMain+mark.m}}
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>

                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{SafetyManagerTraining.trainTimeStart+mark.m}}
                                        </template>
                                        <el-date-picker v-model="formInline.model.trainTimeStart" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" 
                                                        slot="suffix" size="mini" placeholder="选择日期">
                                        </el-date-picker>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                        <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                            <div class="elst-select-mini">
                                <el-form-item>
                                    <el-input size="mini">
                                        <template slot="prepend">
                                            {{SafetyManagerTraining.trainTimeEnd+mark.m}}
                                        </template>
                                        <el-date-picker v-model="formInline.model.trainTimeEnd" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd" 
                                                        slot="suffix" size="mini" placeholder="选择日期">
                                        </el-date-picker>
                                    </el-input>
                                </el-form-item>
                            </div>
                        </el-col>
                    </el-row>
                </el-form>
                <!--<el-col :span="4">
                    <div class="tree_lay">
                        <h4 class="title clearfix"><strong>区域</strong></h4>
                        <el-tree :data="TreeData" :props="defaultProps" @node-click="handleNodeClick">
                            <span slot-scope="scope">
                                <span>
                                    <i :class="scope.data.icon"></i>
                                    <template>
                                        <span v-if="scope.data.icon == 'tree-open'" style="color:#12489e">{{ scope.node.label }}</span>
                                        <span v-else-if="scope.data.icon == 'tree-close'"
                                            style="color: #12489e">{{ scope.node.label }}</span>
                                        <span v-else>{{ scope.node.label }}</span>
                                    </template>
                                </span>
                            </span>
                        </el-tree>
                    </div>
                </el-col>-->
                <el-col :span="24">
                    <el-table ref="table" stripe :data="ListItem.tableData" :row-key="getRowKeys"
                              :height="ListItem.tableHeight" border @selection-change="handleSelectionChange"
                              row-style="height:10px" style="width: 100%;">
                        <el-table-column type="expand">
                            <template slot-scope="props">
                                <el-form label-position="left" inline class="demo-table-expand">
                                    <table style="border:1px  solid; width:95%; padding-left:30px" cellpadding="0"
                                           cellspacing="0">
                                        <tr>
                                            <td style="border-right:1px solid ; text-align:center">
                                                {{SafetyManagerTraining.trainMain}}
                                            </td>
                                            <td style="border-right:1px solid; text-align:center">
                                                {{SafetyManagerTraining.local}}
                                            </td>
                                            <td style="border-right:1px solid; text-align:center">
                                                {{SafetyManagerTraining.trainTime}}
                                            </td>
                                            <td style="text-align:center;width:53px">{{col.btnUpdate}}</td>
                                            <td style="text-align:center;width:53px">{{col.btnDelete}}</td>
                                        </tr>
                                        <tr v-for="todo in props.row.zB_SafetyTrainerDetail">
                                            <td style="border-right:1px solid; text-align:center">
                                                {{todo.trainMain}}
                                            </td>
                                            <td style="border-right:1px solid; text-align:center">
                                                {{todo.local}}
                                            </td>
                                            <td style="border-right:1px solid; text-align:center">
                                                {{todo.trainTime}}
                                            </td>
                                            <td style=" text-align:center">
                                                <button type="button" class="elst-bt-xg" @click=UserInput('xg',todo.id)>
                                                    <i class="el-icon-edit"></i>
                                                </button>
                                            </td>
                                            <td style=" text-align:center">
                                                <button type="button" class="elst-bt-xg"
                                                        @click=deleteChildren(todo.id,todo.Pid)>
                                                    <i class="el-icon-delete"></i>
                                                </button>
                                            </td>
                                        </tr>
                                    </table>
                                </el-form>
                            </template>
                        </el-table-column>
                        <!--<el-table-column type="selection" style=" padding-top: 0px;  padding-bottom: 0px;  " align="center"
        width="55" :reserve-selection="true">
    </el-table-column>-->
                        
                        <el-table-column type="index" :label="col.SequenceNumber" :index="indexMethod" width="50"
                                         show-overflow-tooltip="true"></el-table-column>
                        <el-table-column label="公司" prop="createFactoryText">
                        </el-table-column>
                        <el-table-column :label="SafetyManagerTraining.name" prop="name">
                        </el-table-column>
                        <el-table-column :label="SafetyManagerTraining.type" prop="type" min-width="100">
                            <template scope="scope">
                                <span v-if="scope.row.sysDataDic.key==='0'">否</span>
                                <span v-else>是</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="SafetyManagerTraining.trainedNumber" prop="qualifiedTrainNumber" min-width="100">
                        </el-table-column>
                        <el-table-column :label="SafetyManagerTraining.qualifiedTrainNumber" prop="trainedNumber"
                                         min-width="120">
                        </el-table-column>
                        <!-- <el-table-column :label="SafetyManagerTraining.lastTrainTime" prop="lastTrainTime" width="160">
    </el-table-column> -->
                        <el-table-column :label="SafetyManagerTraining.yOrN" width="180">
                            <template scope="scope">
                                <span v-if="scope.row.qualifiedTrainNumber>=scope.row.trainedNumber">是</span>
                                <span v-else>否</span>
                            </template>
                        </el-table-column>
                        <el-table-column v-if="show" :label="SafetyManagerTraining.year" prop="year">
                        </el-table-column>
                        <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                            <template slot-scope="scope">
                                <!-- <el-button type="primary" @click="UserInputChildren('xg',scope.row.id)"><i class="el-icon-plus"></i>
            </el-button> -->
                                <button type="button" class="elst-bt-xg" @click=UserAdd('xg',scope.row.id)>
                                    <i class="el-icon-edit"></i>
                                </button>
                            </template>
                        </el-table-column>
                        <el-table-column width="53" prop="update" :label="col.btnAdd" fixed="right">
                            <template slot-scope="scope">
                                <button type="button" class="elst-bt-xg" @click="UserInputChildren('xg',scope.row.id)">
                                    <i class="el-icon-plus"></i>
                                </button>
                            </template>
                        </el-table-column>
                    </el-table>
                <el-row type="flex" justify="end">
                    <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes"
                        :page-size="ListItem.pagesize" :layout="ListItem.layout" :total="ListItem.total">
                    </el-pagination>
                </el-row>
                </el-col>
            </el-col>
        </el-row>
        <el-dialog title="安全管理师培训管理"  fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%"
            height="80%" top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        var nowDate = new Date();
        let date = {
            year: nowDate.getFullYear(),
            month: nowDate.getMonth() + 1,
            date: nowDate.getDate(),
        }
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    //TreeData: [],
                    //mydata: RiskControlInformation,
                    //defaultProps: {
                    //    children: 'children',
                    //    label: 'label'
                    //},
                    ListItem: ListItem,
                    show: false,
                    createFactory:[],
                    type: [],
                    value1: '',
                    formInline: {
                        model: {
                            createTime: nowDate,
                            createFactory:"",
                            name: "",
                            type: "",
                            qualifiedTrainNumber: "",
                            trainedNumber: "",
                            lastTrainTime: "",
                            yOrN: "",
                            trainMain: "",
                            local: "",
                            trainTime: "",
                            zB_SafetyTrainerDetail: [],
                            //TreeNode: "",
                            trainTimeStart: "",
                            trainTimeEnd: ""
                        },
                        offset: 0,
                        limit: 10
                    }
                }
            },
            created: function () {
            },
            mounted: function () {
                //this.type = getDicData('n76');
                this.formInline.model.createTime = nowDate;
                this.getTypeList();
                this.getdData();
                this.GetPageData(1);
                //console.log(this);
                //列表高度自适应
                tablehigh(this);
                //this.TreeData = fn(this.mydata, "0");
            },
           
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                Template: function () {
                    window.open("/HeadquartersHSEOffice/安全管理师培训.xlsx");
                    //this.$message({
                    //    message: '模版下载成功！',
                    //    type: 'success'
                    //});
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                //handleNodeClick: function (data) {
                //    if (!data.children) {
                //        this.formInline.model.TreeNode = data.id
                //        onSubmit(this);
                //    } else {
                //        if (data.icon == "tree-open") {
                //            data.icon = "tree-close"
                //        } else (
                //            data.icon = "tree-open"
                //        )
                //    }
                //},
                deleteChildren: function (id, Pid) {
                    this.$confirm(' 是否确认继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(function () {
                        //for (var i = 0; i < this.ListItem.tableData.length; i++) {
                        //    if (this.ListItem.tableData[i].id == Pid) {
                        //        var item = this.ListItem.tableData[i].zB_SafetyTrainerDetail;
                        //        for (var j = 0; j < item.length; j++) {
                        //            if (item[j].id == id) {
                        //                item.splice(j, 1);
                        //                break;
                        //            };
                        //        };
                        //    };
                        //};
                        //showMessage(msg.OperatingOk, "success");
                        myAjax("post", this, "/api/ZB_SafetyTrainerDetail/DeleteMuti", [id], function (response) {
                            this.GetPageData(1);
                            this.ListItem.currentPage = 1;
                            showMessage(msg.OperatingOk, "success");
                        });

                    }).catch(function () {
                        showMessage("已取消删除!");
                    });
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/ZB_SafetyTrainer/DeleteMuti'); },
                //列表选择触发 
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //Dialog展示
                UserAdd: function (val, id) { DialogShow(this, val, "SafetyManagerTrainingInputUser.html", id); },
                UserInput: function (val, id) { DialogShow(this, val, "SafetyManagerTrainingInput.html", id); },
                UserInputChildren: function (val, id) {
                    DialogShow(this, val, "SafetyManagerTrainingInput.html", id, "type=tj");
                },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/ZB_SafetyTrainer/GetList') },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                //初始管理师类型
                getTypeList: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/CBS_DayCheckItem/CBSsglbGetList', { model: { category: 'zbglspx' }, offset: 0, limit: 100 }, function (response) {
                        mythis.type = response.data;

                        //console.log(response.data.pageData);
                    }, false);
                },
                //工厂
                getdData: function () {
                    var url = "/api/WebPageInitial/FactoryListAll";
                    var app = this;
                    myAjax("get", this, url, null, function (response) {
                        app.createFactory = response.data;

                    }, false);

                    //if (this.data && this.data.length > 0)
                    //this.model = this.data[0].key;
                },
            }
        });
        
    </script>

</body>

</html>